home *** CD-ROM | disk | FTP | other *** search
- // ---------------------------------------------------------------------------
- // • AVF 1.1 - Asynchronous Video Framework
- // •
- // • Philippe Lang, 1733 Treyvaux, SWITZERLAND
- // • plang@com.mcnet.ch
- // ---------------------------------------------------------------------------
- // This program demonstrates the uses of AVF with a BW QuickCam Camera
-
- #include "VideoSession.h"
- #include "OffscreenWorld.h"
- #include "OffscreenGroup.h"
- #include "AsyncBuffer.h"
-
- enum mainErr { NewCWindowErr };
-
- main()
- {
- // initialisation
- InitGraf( &qd.thePort );
- InitFonts();
- FlushEvents( everyEvent, 0 );
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( nil );
- InitCursor();
-
- MoreMasters();
- MoreMasters();
- MaxApplZone();
- MaxApplZone();
-
- // program starts here
- try
- {
- VideoSession theSession( ConnectixVdig );
- Rect theOffscreenRect = {0, 0, 120, 160};
- OffscreenWorld theImage0( 16, theOffscreenRect, GetCTable(36) );
- OffscreenWorld theImage1( 16, theOffscreenRect, GetCTable(36) );
- OffscreenWorld theImage2( 16, theOffscreenRect, GetCTable(36) );
- OffscreenGroup theImageGroup;
- theImageGroup.AddOffWorldPtr( &theImage0 );
- theImageGroup.AddOffWorldPtr( &theImage1 );
- theImageGroup.AddOffWorldPtr( &theImage2 );
- AsyncBuffer theBuffer( &theSession, &theImageGroup );
-
- WindowPtr theWin;
- Rect theWinPos = {100, 100, 220, 260};
- theWin = NewCWindow( nil, &theWinPos, "\pVdig", true, movableDBoxProc, (WindowPtr)-1, 0, 0 );
- if ( theWin == nil ) throw NewCWindowErr;
- SetPort( theWin );
-
- VDGrabOneFrameAsync( theSession.VdigComponent(), 1 );
- do
- {
- while ( !VDDone( theSession.VdigComponent(), 0 ) ) {};
- VDGrabOneFrameAsync( theSession.VdigComponent(), 2 );
- CopyBits( (BitMap*)*theImage2.PixMapH(), &theWin->portBits, &theOffscreenRect, &theOffscreenRect, srcCopy, nil );
-
- while ( !VDDone( theSession.VdigComponent(), 1 ) ) {};
- VDGrabOneFrameAsync( theSession.VdigComponent(), 0 );
- CopyBits( (BitMap*)*theImage0.PixMapH(), &theWin->portBits, &theOffscreenRect, &theOffscreenRect, srcCopy, nil );
-
- while ( !VDDone( theSession.VdigComponent(), 2 ) ) {};
- VDGrabOneFrameAsync( theSession.VdigComponent(), 1 );
- CopyBits( (BitMap*)*theImage1.PixMapH(), &theWin->portBits, &theOffscreenRect, &theOffscreenRect, srcCopy, nil );
- }
- while ( !Button() );
-
- DisposeWindow( theWin );
- }
-
- // exception handlers
- catch ( VideoErr theErr )
- {
- SysBeep(0);
- ExitToShell();
- }
-
- catch ( OffscreenErr theErr )
- {
- SysBeep(0);
- ExitToShell();
- }
-
- catch ( AsyncBufferErr theErr )
- {
- SysBeep(0);
- ExitToShell();
- }
-
- catch ( mainErr theErr )
- {
- SysBeep(0);
- ExitToShell();
- }
-
- catch ( OffscreenGroupErr theErr )
- {
- SysBeep(0);
- ExitToShell();
- }
-
- // program is finished
- return (1);
- };
-